package com.lky.marshallmall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * Created by
 * autor : Marshall lky
 * datetime: 2021/4/1 13:54
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对redis的操作都要通过redissonclient
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() throws IOException {
        //创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://172.16.11.177:6379");
        //创建返回实例
        return Redisson.create(config);
    }

}
